﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class PopupContainerMediator extends Mediator {

		[Inject]
        public var popupModel:PopupModel;

        override public function onRegister():void{
            super.onRegister();
            addContextListener(EventConstants.SHOW_POPUP, this.onShowPopup, InfoEvent);
            addContextListener(EventConstants.CLOSE_POPUP, this.onClosePopup, InfoEvent);
            this.view.hide();
            this.popupModel.isSending = true;
            this.popupModel.showNextInQueue();
        }
        private function get view():PopupContainerView{
            return ((viewComponent as PopupContainerView));
        }
        private function onShowPopup(_arg1:InfoEvent):void{
            this.view.show();
            var _local2:IPopupView = (_arg1.info as IPopupView);
            this.view.addChild(_local2.component);
        }
        private function onClosePopup(_arg1:InfoEvent):void{
            var _local2:IPopupView = (_arg1.info as IPopupView);
            _local2.component.remove();
            if (!this.popupModel.hasOpenPopups){
                this.view.hide();
            };
        }

    }
}//package net.wooga.pets.views.popups 
